import { defineStore } from 'pinia'
import { _login } from '@/api/index'
// import { type Alltype } from '@/types/index'
export const useCounterStore = defineStore('Alltype', {
  state() {
    return {
      token: '',
      user_id: '',
      img: '',
      isCollapse: true
    }
  },
  actions: {
    async loginActive(params: any) {
      const { data } = await _login(params)
      console.log(data)
      this.token = data.data.token
      this.user_id = data.data.user_id
      this.img = data.data.image
      localStorage.setItem('token', this.token)
      localStorage.setItem('user_id', this.user_id)
      localStorage.setItem('img', this.img)
      window.location.href = '/'
    },
    changeisCollapse() {
      this.isCollapse = !this.isCollapse
    }
  }
})
